<?php
// 判断全局变量是否存在LoginAdmin
if (isset($_COOKIE['LoginAdmin'])) {
    // 判断LoginAdmin是否有值
    $LoginAdmin = !empty($_COOKIE['LoginAdmin']) ? json_decode($_COOKIE['LoginAdmin'], true) : [];

    $Adminid = isset($LoginAdmin['id']) ? $LoginAdmin['id'] : 0;

    $sql = "select * from `pre_admin` where `id` = '$Adminid'";

    $admin = find($sql);

    if (!$admin) {
        setcookie('LoginAdmin', null, time() - 1);
        ShowMsg('非法登录！', 'login.php');
    }
} else {
    ShowMsg('请先登录！', 'login.php');
}

?>
<style>
    .user{
        border-radius: 50%;
    }

    .user img{
        width: 20px;
        height: 20px;
        border-radius: 50%;
    }
</style>
<div class="navbar">
    <div class="navbar-inner">
        <ul class="nav pull-right">
            <li>
                <a href="" role="button">
                    <i class="user">
                        <img src="<?php echo $LoginAdmin['avatar']; ?>" />
                    </i>
                    <?php echo $LoginAdmin['username'] ?>
                </a>
            </li>
            <li>
                <a href="index.php?action=Logout" class="hidden-phone visible-tablet visible-desktop" role="button" onclick="return confirm('确认退出账号？')">Logout</a>
            </li>
        </ul>
        <a class="brand" href="index.php"><span class="second">Admin</span></a>
    </div>
</div>